#include "sattribute.h"

#include <cassert>

extern "C" {
#include <hdf/mfhdf.h>
}

namespace sds {

  SAttribute::SAttribute(int fileId, int index) 
    : fileId(fileId), index(index) {
    char nameTmp[MAX_NC_NAME];
    SInteger typeTmp;
    SInteger status = SDattrinfo(fileId, index, nameTmp, &typeTmp, &length);
    assert(status != FAIL);
    name = nameTmp;
    dataType = SDataTypeConverter::convert(typeTmp);
  }

  SAttribute::~SAttribute() {}

  void SAttribute::readBuffer(void* data) const {
    SDreadattr(fileId, index, data);
  }

}
